package com.citro.agents;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.Map;

/**
 * Browser behavior event data model
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class BehaviorEvent implements Serializable {

    @JsonProperty("userId")
    private String userId;

    @JsonProperty("eventType")
    private String eventType;

    @JsonProperty("timestamp")
    private Long timestamp;

    @JsonProperty("sessionId")
    private String sessionId;

    @JsonProperty("contextId")
    private String contextId;

    @JsonProperty("url")
    private String url;

    @JsonProperty("title")
    private String title;

    @JsonProperty("eventData")
    private Map<String, Object> eventData;

    @JsonProperty("globalStructure")
    private Map<String, Object> globalStructure;

    @JsonProperty("interactionContext")
    private Map<String, Object> interactionContext;

    @JsonProperty("mutationContext")
    private Map<String, Object> mutationContext;

    @JsonProperty("tabId")
    private Integer tabId;

    @JsonProperty("frameId")
    private Integer frameId;

    @JsonProperty("tabTitle")
    private String tabTitle;

    @JsonProperty("tabUrl")
    private String tabUrl;

    // Default constructor for Jackson
    public BehaviorEvent() {}

    // Getters and Setters
    public String getUserId() {
        // 默认值 'unknown'，与 Python 版本保持一致
        return userId != null ? userId : "unknown";
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getEventType() {
        return eventType;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getContextId() {
        return contextId;
    }

    public void setContextId(String contextId) {
        this.contextId = contextId;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Map<String, Object> getEventData() {
        return eventData;
    }

    public void setEventData(Map<String, Object> eventData) {
        this.eventData = eventData;
    }

    public Map<String, Object> getGlobalStructure() {
        return globalStructure;
    }

    public void setGlobalStructure(Map<String, Object> globalStructure) {
        this.globalStructure = globalStructure;
    }

    public Map<String, Object> getInteractionContext() {
        return interactionContext;
    }

    public void setInteractionContext(Map<String, Object> interactionContext) {
        this.interactionContext = interactionContext;
    }

    public Map<String, Object> getMutationContext() {
        return mutationContext;
    }

    public void setMutationContext(Map<String, Object> mutationContext) {
        this.mutationContext = mutationContext;
    }

    public Integer getTabId() {
        return tabId;
    }

    public void setTabId(Integer tabId) {
        this.tabId = tabId;
    }

    public Integer getFrameId() {
        return frameId;
    }

    public void setFrameId(Integer frameId) {
        this.frameId = frameId;
    }

    public String getTabTitle() {
        return tabTitle;
    }

    public void setTabTitle(String tabTitle) {
        this.tabTitle = tabTitle;
    }

    public String getTabUrl() {
        return tabUrl;
    }

    public void setTabUrl(String tabUrl) {
        this.tabUrl = tabUrl;
    }

    @Override
    public String toString() {
        return "BehaviorEvent{" +
                "eventType='" + eventType + '\'' +
                ", timestamp=" + timestamp +
                ", sessionId='" + sessionId + '\'' +
                ", url='" + url + '\'' +
                ", title='" + title + '\'' +
                '}';
    }
}
